<template>
    <div class="user">
        <div class="content" >
            <el-main>
                <el-table
                    border
                    :fit="true"
                    :data="tableData.slice((currentPage - 1) * pageSize,currentPage * pageSize)"
                >
                    <el-table-column
                        prop="_id"
                        label="序号"
                    ></el-table-column>
                    <el-table-column
                        prop="usr"
                        label="用户名"
                    ></el-table-column>
                    <el-table-column
                        prop="pwd"
                        label="密码"
                    ></el-table-column>
                </el-table>
                <pageNation
                    :total="tableData.length"
                    :page-size="pageSize"
                    @pageChange="pageChange"
                    :page_index="currentPage"
                />
            </el-main>
        </div>
    </div>
</template>
<script>
    import pageNation from "../../components/pagenation/pageNation";
    export default {
        name: "User",
        components: { pageNation },
        data() {
            return {
                pageSize: 10,
                currentPage: 1,
                tableData: []
            };
        },
        mounted(){
            this.$http.get("/api/user/findUserAll").then(res=>{
                if(res.data.code===200){
                    this.tableData=res.data.result
                }else{
                    this.$message.error("没有对应数据！");
                }
            })
        },
        methods: {
            //分页
            pageChange(item) {
                this.currentPage = item.page_index;
                this.pageSize = item.page_limit;
            },
        }
    }
</script>
<style lang="less" scoped>
    .user {
        width: 100%;
        height: 91vh;
        background-color: #fff;
    }
</style>